﻿
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    var citys = [];

    $(function () {
        $.ajax({
            url: "/OrderFlowManage/ClientOrder/GetCitysJson",
            data: {},
            dataType: "json",
            async: false,
            success: function (data) {
                citys = data;
                gridList();
            }
        });
    })
    function gridList() {
        var $gridList = $("#gridList");
        var flowStateArr = ['订单指派', '场地推荐', '带看场地', '意向场地报价', '价格审核', '场地预定', '用印申请', '签订合同', '订单完成'];

        var flowOrderStateArr = ['等待确认', '通过', '驳回'];
        var stateArr = ['无效', '有效', '信息不完整'];

        $gridList.dataGrid({
            url: "/OrderFlowManage/ClientOrder/GetCloseOrderGridJson",
            height: $(window).height() - 176,
            colModel: [
                {
                    label: '活动城市', name: 'F_ActivityCityId', width: 70, sortable: false, align: 'left',
                    formatter: function (cellvalue, options, rowObject) {
                        if (cellvalue) {
                            var arr = cellvalue.indexOf(',') == -1 ? [cellvalue] : cellvalue.split(',');
                            var result = [];
                            for (var i = 0; i < citys.length; i++) {
                                var ele = citys[i];
                                for (var j = 0; j < arr.length; j++) {
                                    var val = arr[j];
                                    if (val == ele.Value) {
                                        result.push(ele.Text);
                                    }
                                }
                            }
                            return result.toString();
                        }
                        return '';
                    }
                },
                {
                    label: '活动日期', name: 'F_ActivityStartDate', width: 180, align: 'center', sortable: false,
                    formatter: function (cellvalue, options, rowObject) {
                        var start = cellvalue ? cellvalue.split(' ')[0] : '';
                        var end = rowObject.F_ActivityEndDate ? rowObject.F_ActivityEndDate.split(' ')[0] : '';
                        return start + '~' + end;
                    }
                },
                { label: '活动主题', name: 'F_ActivityTheme', width: 250, sortable: false, align: 'left' },
                { label: '活动类型', name: 'F_ActivityTypeName', width: 150, sortable: false, align: 'left' },
                {
                    label: '预算金额(元)', name: 'F_DemandCash', width: 80, align: 'left', sortable: false,
                    formatter: function (cellvalue, options, rowObject) {
                        return (cellvalue || "").toString();
                    }
                },
                { label: '场地大小(㎡)', name: 'F_SiteArea', width: 100, sortable: false, align: 'left' },
                { label: '联系人', name: 'F_Contact', width: 60, sortable: false, align: 'left' },
                { label: '公司名称', name: 'F_ClientName', width: 180, sortable: false, align: 'left' },
                {
                    label: '订单进度', name: 'F_OrderState', width: 80, align: 'left',
                    formatter: function (cellvalue, options, rowObject) {
                        // 0指派 1 场地推荐 2 带看场地 3 意向场地 4 价格谈判 5 价格谈判 6 场地预定 7 用印申请 8 签订合同 9 订单完成
                        return flowStateArr[cellvalue] || '';
                    }
                },
                {
                    label: '进度状态', name: 'F_OrderStateProcess', width: 80, align: 'left',
                    formatter: function (cellvalue, options, rowObject) {
                        // -1 等待跟进  0等待确认    1通过    2驳回
                        return cellvalue == -1 ? "等待跟进" : flowOrderStateArr[cellvalue];
                    }
                },
                {
                    label: '状态', name: 'F_State', width: 50, align: 'left',
                    formatter: function (cellvalue, options, rowObject) {
                        // 订单状态:0:无效,1:有效，2：信息不完整
                        //return stateArr[cellvalue] || '';
                        return '无效';
                    }
                },
                { label: '跟进人', name: 'F_FlowUserName', width: 60, sortable: false, align: 'left' },

                {
                    label: '更新时间', name: 'F_LastModifyTime', width: 100, align: 'center',
                    formatter: "date", formatoptions: { srcformat: 'Y-m-d H:i', newformat: 'Y-m-d H:i' }
                },
                {
                    label: '创建时间', name: 'F_CreatorTime', width: 100, align: 'center',
                    formatter: "date", formatoptions: { srcformat: 'Y-m-d H:i', newformat: 'Y-m-d H:i' }
                },
                { label: '编号', name: 'F_Id', hidden: true }
            ],
            //postData: {
            //    environment: 1,
            //    type: pageType
            //},
            pager: "#gridPager",
            sortname: 'F_LastModifyTime',
            viewrecords: true
        });
    }

    //function btn_add() {
    //    $.modalOpen({
    //        id: "Form",
    //        title: "添加带看",
    //        url: "/OrderFlowManage/TakelookAllot/Form",
    //        width: "500px",
    //        height: "300px",
    //        callBack: function (iframeId) {
    //            top.frames[iframeId].submitForm();
    //        }
    //    });
    //}
</script>

<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        @*<div class="btn-group">
            <a class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-eraser"></i>添加带看</a>
        </div>*@
    </div>
    <div class="search">
        @*<table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txt_keyword" type="text" class="form-control" placeholder="请输入要查询关键字" style="width: 200px;">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>*@
    </div>
</div>

<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>